package coin.yang.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 构建CDemo类
        CDemo c = new CDemo();
        // 构建Task任务
        FutureTask<String> task = new FutureTask<>(c);
        // 构建Thread线程
        Thread t = new Thread(task);
        // 启动线程
        t.start();
        // 获取结果
        String s = task.get();
        System.out.println(s);
    }
}

class CDemo implements Callable<String> {
    @Override
    public String call() throws Exception {
        return "SUCCESS";
    }
}
